﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SearchUI.Models;

namespace SearchUI.Controllers
{
	[HandleError]
	public class SearchController : Controller
	{
		public ActionResult Index()
		{
			SearchModel model = new SearchModel();
			return View(model);
		}

		public ActionResult About()
		{
			return View();
		}

		public ActionResult RunSearch(string search_terms, string search_id, string sortBy, string reverseSort, string format)
		{

			SearchModel model = new SearchModel();
			CompareField SearchSort = CompareField.Rank;
			if (sortBy != String.Empty)
			{
				SearchSort = (CompareField)Enum.Parse(typeof(CompareField), sortBy, true);
			}
			model.RunSWISHESearch(search_terms, Request.ApplicationPath.Replace("/",String.Empty), SearchSort, reverseSort, format);
			return View(model);

		}
	}
}